<template>
<table>
    <tr>
        <td>用户名</td>
        <td><input type="text" v-model="UserName"></td>
    </tr>
    <tr>
        <td>密码</td>
        <td><input type="password" v-model="Upwd"></td>
    </tr>
    <tr>
        <td colspan="2"><button @click="Regit">注册</button></td>
    </tr>
</table>
</template>
<script setup lang="ts">
import axios from 'axios';
import {ref} from 'vue'
const UserName=ref()
const Upwd=ref()

const Regit=()=>{
if(!UserName.value){
    alert("用户名不能为空")
    return
}
if(!Upwd.value){
    alert("密码不能为空")
    return
}
if(UserName.value.length<6){
    alert("用户名长度不能少于6")
    return
}
if(Upwd.value.length<6){
    alert("密码长度不能少于6")
    return
}
    axios.post('https://localhost:44312/api/Lx/Regit',
        {
            UserName:UserName.value,
            Upwd:Upwd.value,
            Usex:"男",
            Uage:19
        }
    )
    .then(res=>{
        if(res.data>0){
            alert("添加成功")
            return
        }else{
            alert("添加失败")
        }
    }).catch(error=>{
        console.log(error)
    })
}

</script>